import {Form, Switch} from 'antd'
import {omit} from 'ramda'
import Group from './Group'

const FormItem = Form.Item;

// type SwitchPropsType = {
//     initialValue?: boolean,
//     name: string,
//     labelCol?: number,
//     getFieldDecorator: Function,
//     span?: number,
//     textAlign?: 'riught' | 'cxenter' | 'left',
//     label?: string | number
// }


const FormSwitch = ({getFieldDecorator, span, textAlign, initialValue, name, labelCol, label}) => (
    <Group spans={[span || 16]} textAligns={[textAlign || 'left']}>
        <FormItem labelCol={{span: labelCol || 0}} wrapperCol={{span: 16 - (labelCol || 0)}} label={label}>
            {getFieldDecorator(name, {
                initialValue,
            })(<Switch defaultChecked={initialValue}/>)}
        </FormItem>
    </Group>
)

export default FormSwitch